package com.cino.config;

import com.cino.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;


/**
 *  告诉springmvc 我拦截哪些请求
 *
 */
@Configuration
public class LoginWebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private  LoginInterceptor loginInterceptor;

    /**
     * 把登录拦截器进行注册
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        /*
           addInterceptor 把登录拦截器进行注册
           addPathPatterns 拦截哪些请求
           excludePathPatterns 不拦截哪些请求
         */
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login");
    }
}
